package com.gxa.modules.app.hospital.health.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Query;
import com.gxa.modules.app.hospital.health.mapper.HealthMapper01;
import com.gxa.modules.app.hospital.health.service.HealthService01;
import com.gxa.modules.model.entity.hospital.Health;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 健康百科文章表 服务实现类
 * </p>
 *
 * @author lst
 * @since 2022-11-11
 */
@Service
@Slf4j
public class HealthService01Impl extends ServiceImpl<HealthMapper01, Health> implements HealthService01 {

    @Autowired
    private HealthMapper01 healthMapper01;

    /*
    分页查询所有
     */
    @Override
    public PageUtils queryByPage(Map<String, Object> params) {
        IPage<Health> page = this.page(new Query<Health>().getPage(params));
        PageUtils pageUtils = new PageUtils(page);
        return pageUtils;
    }

    /**
     * 带条件的分页查询
     */
    @Override
    public PageUtils queryByTitle(Map<String, Object> params) {
        String title = (String) params.get("title");

        IPage<Health> page = this.page(new Query<Health>().getPage(params), new QueryWrapper<Health>().likeRight(StringUtils.isNotEmpty(title), "title", title));

        return new PageUtils(page);
    }

    @Override
    public Health queryById(Integer id) {

        return healthMapper01.selectById(id);
    }


}
